﻿using M_Process.API.Appliction.Command.ProcessRouteCommand;
using M_Process.Repository.ProcessInterface;
using MediatR;

namespace M_Process.API.Appliction.CommandHandlers.ProcessRouteHandler
{
    /// <summary>
    /// 单删（工艺信息）
    /// </summary>
    public class ProcessRouteDeleteCommandHandler : IRequestHandler<ProcessRouteDeleteCommand, int>
    {
        private readonly IProcessRouteRepository _processRouteRepository;
        public ProcessRouteDeleteCommandHandler(IProcessRouteRepository processRouteRepository)
        {
            _processRouteRepository = processRouteRepository;
        }
        public async Task<int> Handle(ProcessRouteDeleteCommand request, CancellationToken cancellationToken)
        {
            var del = await _processRouteRepository.GetModelsAsync(request.ProcessRouteId);
            del.IsDeleted = true;
            return await _processRouteRepository.UpdateAsync(del);
        }
    }
}
